package com.ship.contract.bean;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ship.common.core.base.BaseBean;
import com.ship.common.core.base.Joinable;
import com.ship.common.core.mapping.Label;
import com.ship.common.core.mapping.SearchItem;
import com.ship.common.core.mapping.TableColumn;
import com.ship.common.core.validate.Add;
import com.ship.common.core.validate.Update;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;

@TableName("sp_fob_sublease")
@Data
public class SpFobSublease extends BaseBean implements Joinable {

//    @Label(value="合同id")
//    @TableColumn
    private Long conId;
    /**
     *合同编号
     */
    @Label(value="合同编号")
    @SearchItem
    @TableColumn
    private String contractNumber;

    /**
     *合同名称
     */
    @Label(value="合同名称")
    @SearchItem
    @TableColumn
    private String contractName;

    /**
     *合同类型（租入长期船、租入短期船、船舶租出、内部转租）
     */
    @Label(value="合同类型",enumContent = "船运合同类型",multiSelect = true)
    @SearchItem
    private Integer contractType;

    @Label(value="合同类型",enumContent = "船运合同类型",multiSelect = true)
    @TableColumn
    @SearchItem
    @TableField(exist = false)
    private String contractTypeStr;

    @TableField(exist = false)
    private String contractTypeListForSearch;

    /**
     *贸易主体(国贸、新贸)
     */
    @Label(value="贸易主体",enumContent = "贸易主体",multiSelect = true)
    @SearchItem
//    @TableColumn
    @NotNull(message = "贸易主体不能为空", groups = {Add.class})
    private Integer tradeBody;



    @Label(value="贸易主体·采购")
    @TableColumn
    @TableField(exist = false)
    private String tradeBodyStr;

    /**
     *签订日期
     */
    @Label(value="签订日期")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @SearchItem
    @TableColumn
    private Date signingDate;

    /**
     *IMO
     */
    @Label(value="IMO")
    @TableColumn
    @NotBlank(message = "IMO不能为空", groups = {Update.class, Add.class})
    @Size(max = 255, message = "IMO长度不能超过255", groups = {Update.class, Add.class})
    private String imo;

    /**
     *船舶名称
     */
    @Label(value="船舶名称")
    @TableColumn
    @NotBlank(message = "船舶名称不能为空", groups = {Update.class, Add.class})
    @Size(max = 255, message = "船舶名称长度不能超过255", groups = {Update.class, Add.class})
    private String shipName;


    @Label(value = "完成时间")
    @TableColumn
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private Date finishTime;
//    @Label(value = "流程实例id")
//    @TableColumn
    private String processInstanceId;
    @Label(value = "状态",enumContent = "船运执行状态",multiSelect = true)
//    @TableColumn
    @SearchItem
    private Integer status;

    @Label(value="状态",enumContent = "状态",multiSelect = true)
    @TableField(exist = false)
    @TableColumn
    private String statusStr;
    public String getStatusStr(){
        String result = null;
        if (getStatus()!=null){
            Integer type = getStatus();
            if(type==0){
                result="进行中";
            }
            if (type == 1){
                result = "完成";
            }
            if (type == 2 || type==-1){
                result = "已终止";
            }
        }
        return result;
    }

    @TableField(exist = false)
    private String statusListForSearch;
    @Label(value = "流程执行人")
    @TableColumn
    private String assigeners;
    public String getTradeBodyStr(){
        String result = null;
        if (getTradeBody()!=null){
            Integer type = getTradeBody();
            if (type == 1){
                result = "国贸";
            }
            if (type == 2){
                result = "新贸";
            }
        }
        return result;
    }

    public String getContractTypeStr(){
        String result = null;
        if(getContractType()!=null){
            if(getContractType()==1){
                result = "租入长期船";
            }else if(getContractType()==2){
                result = "租入短期船";
            }else if(getContractType()==3){
                result = "船舶租出";
            }else if(getContractType()==4){
                result = "内部转租";
            }
        }
        return result;
    }
    @Override
    public String getLabel() {
        return null;
    }

    @Override
    public String getValue() {
        return null;
    }
}
